package cn.itcast.web.controller;

import cn.itcast.domain.system.User;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
/*该类的作用：把所有Controller公共部门抽取出去，减少重复代码的编写*/
public class BaseController {
    @Autowired
    protected HttpServletRequest request;

    @Autowired
    protected HttpServletResponse response;

    @Autowired
    protected HttpSession session;

    //获取登陆者
    public User getLoginUser(){
        User user = (User) session.getAttribute("loginUser");
        return user;
    }

    //获取登陆者企业id
    public String getLoginUserCompanyId(){
        return getLoginUser().getCompanyId();
    }

    //获取登陆者企业名称
    public String getLoginUserCompanyName(){
        return getLoginUser().getCompanyName();
    }
}
